<template>
    <div class="dialog">
        <Phone :openId="openId" v-if="DlogType === 'phone'" :phone="phone" :captchaVerification="captchaVerification" @close="close" @setdialogType="setdialogType" />
        <DragVerify v-if="DlogType === 'dragVerify'" @close="close" @setdialogType="setdialogType" @DragVerifycallback="DragVerifycallback" />
    </div>
</template>

<script>
import Phone from "./dialogTypes/phone.vue";
import DragVerify from "./dialogTypes/DragVerify.vue";

export default {
    components: {
        Phone,
        DragVerify
    },
    props: {
        dialogType: String,
        openId: String
    },
    data() {
        return {
            phone: "",
            captchaVerification: "",
            DlogType: '',
        };
    },
    watch: {
        dialogType(v) {
            this.DlogType = v;
        },
    },
    mounted() {
        this.DlogType = this.dialogType;
    },
    methods: {

        setdialogType(type, params) {
            this.DlogType = type;
            if (type === 'dragVerify' && params.phone) {
                this.phone = params.phone;
            }
            if (type === 'phone' && params.captchaVerification) {
                this.captchaVerification = params.captchaVerification;
            }
        },
        close(target) {
            if (target === this.DlogType) {
                this.$emit('closeDialog');
            }
        },
        DragVerifycallback(callbackParams) {
            // 假设DragVerifycallback是一个来自父组件的方法，这里直接调用它
            // 如果DragVerifycallback是作为prop传递且需要处理逻辑，请根据实际情况调整
            this.$emit('DragVerifycallback', callbackParams);
        }
    },
    provide() {
        return {
            openId: this.openId
        };
    }
};
</script>

<style lang="less" scoped>
.dialog {
    width: 100vw;
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000;
    background-color: rgba(0, 0, 0, 0.7);
}
</style>